<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
    <th:block th:include="include :: header('修改设备仓库信息')"/>
    <th:block th:include="include :: select2-css"/>
</head>
<body>
<div class="main-content">
    <form class="form-horizontal" id="form-user-edit" th:object="${cargo_area}">
        <h4 class="form-header h4">设备库房区域信息</h4>
        <div class="row">
            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label is-required">货区id：</label>
                    <div class="col-sm-8">
                        <input name="cargo_area_id" th:field="*{cargo_area_id}" class="form-control" type="text"
                               maxlength="30" readonly required>
                    </div>
                </div>
            </div>
            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label is-required">仓库id：</label>
                    <div class="col-sm-8">
                        <input name="warehouse_id" id="warehouse_id" th:field="*{warehouse_id}" type="text"
                               placeholder="请选择归属部门" class="form-control" required>
                    </div>
                </div>
            </div>
        </div>
        <div class="row">
            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label">货区名称：</label>
                    <div class="col-sm-8">
                        <input id="cargo_area_name" name="cargo_area_name" th:field="*{cargo_area_name}"
                               placeholder="请输入货区名称" class="form-control" type="text" maxlength="11">
                    </div>
                </div>
            </div>

            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label">货区描述：</label>
                    <div class="col-sm-8">
                        <input id="c_desc" name="c_desc" class="form-control" th:field="*{c_desc}" type="text"
                               maxlength="50" placeholder="请输入货区描述">
                    </div>
                </div>
            </div>
        </div>
        <div class="row">
            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label ">物资分类id：</label>
                    <div class="col-sm-8">
                        <input id="productkind_id" name="productkind_id" class="form-control" th:field="*{productkind_id}"
                               type="text"
                               maxlength="50" placeholder="请输入货区描述">
                    </div>
                </div>
            </div>
            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label is-required">是否为默认分区：</label>
                    <div class="col-sm-8">
                        <select name="is_default" class="form-control m-b "
                                th:checked="${is_default == 'Y' ? '是' : '否'}" required>
                            <option value="Y">是</option>
                            <option value="N">否</option>
                        </select>
                    </div>
                </div>
            </div>
        </div>
        <div class="row">
            <div class="col-sm-6">
                <div class="form-group">
                    <label class="col-sm-4 control-label">是否锁定：</label>
                    <div class="col-sm-8">
                        <label class="toggle-switch switch-solid">
                            <input type="checkbox" id="locked" th:checked="${locked == '1' ? true : false}">
                            <span></span>
                        </label>
                    </div>
                </div>
            </div>
        </div>

    </form>
</div>
<div class="row">
    <div class="col-sm-offset-5 col-sm-10">
        <button type="button" class="btn btn-sm btn-primary" onclick="submitHandler()"><i class="fa fa-check"></i>保 存
        </button>&nbsp;
        <button type="button" class="btn btn-sm btn-danger" onclick="closeItem()"><i class="fa fa-reply-all"></i>关 闭
        </button>
    </div>
</div>
<th:block th:include="include :: footer"/>
<th:block th:include="include :: select2-js"/>
<script type="text/javascript">
    var prefix = ctx + "device/cargoArea";


    function submitHandler() {
        if ($.validate.form()) {
        	var data = $("#form-user-edit").serializeArray();
        	var locked = $("input[id='locked']").is(':checked') == true ? 0 : 1;
        	data.push({"name": "locked", "value": locked});
        	$.operate.saveTab(prefix + "/edit", data);
        }
    }

</script>
</body>
</html>